from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop029_添加的普通信息标签"
#打开网页，登录后台
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox,"商品管理","商品标签","商品标签分组")
# 点击“添加标签组”，填写标签组名称“华为老大”，标签排序255。
firefox.find_element_by_link_text("添加标签组").click()
firefox.find_element_by_id("tag_group_name").send_keys("华为老大")
firefox.find_element_by_id("tag_group_sort").clear()
firefox.find_element_by_id("tag_group_sort").send_keys("255")
#点击“保存标签组信息”，保存成功
firefox.find_element_by_xpath('(//button[@class="btn btn-small btn-primary"])[2]').click()
# 点击商品管理商品标签商品标签分组
DBshopEnterMenu3(firefox,"商品管理","商品标签","普通商品标签")
# 点击“添加普通商品标签”
firefox.find_element_by_link_text("添加普通商品标签").click()

# 填写标签分组“华为老大”，标签分组“华为手机，华为耳机”，标签排序255.
sel=Select(firefox.find_element_by_id("tag_group_id"))
sel.select_by_visible_text("华为老大")
firefox.find_element_by_id("tag_name").send_keys("华为手机，华为耳机")
firefox.find_element_by_id("tag_sort").clear()
firefox.find_element_by_id("tag_sort").send_keys("255")

# 点击“保存标签信息”，保存成功
firefox.find_element_by_xpath("//button").click()

#断言
s=firefox.find_element_by_xpath('//*/table/tbody/tr/td[4]').text
time.sleep(4)
print(s)

if  s in "华为手机，华为耳机":
    writeLog("%s 测试通过" % (testCase))
else:
    writeLog("%s 测试失败" % (testCase))
    getPhoto(firefox)
firefox.quit()